class ParamsTypeError(Exception):
    pass


def foo_for(n):
    try:
        n = int(n)
        a, b = 0, 1
        list_1 = [a, b]
        if n == 0:
            return [a]
        elif n == 1:
            return [a, b]
        for i in range(n-2):
            a, b = b, a + b
            list_1.append(b)
        return list_1
    except Exception as e:
        raise ParamsTypeError("错误的数据类型")


def foo_while(n):
    try:
        n = int(n)
        a, b = 0, 1
        list_2 = [a, b]
        if n == 0:
            return [a]
        elif n == 1:
            return [a, b]
        i = 0
        while i < n-2:
            a, b = b, a + b
            list_2.append(b)
            i += 1
        return list_2
    except Exception as e:
        raise ParamsTypeError("错误的数据类型")


print(f"斐波那契数列前1-10项分别为:{foo_for('10')}")
print(f"斐波那契数列前1-10项分别为:{foo_while(10.24)}")




